package com.shundr.shipper.common.view;

import com.shundr.shipper.R;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

public class DialogCallPhoneNumber extends Dialog {
	Context context;
	/**
	 * 认证状态
	 */
	int status=5;
	/**
	 * 可拨打电话次数
	 */
	int num;
	TextView tvRenzhengContent,tvCallPhoneNum;
	Button btnFirstButton, btnSecondButton;
	ImageView ivBiaoQing;
	OnCallPhoneDialogListener onCallPhoneDialogListener;

	public DialogCallPhoneNumber(Context context, int status,int num,
			OnCallPhoneDialogListener onCallPhoneDialogListener) {
		super(context, R.style.dialog_style);
		this.context = context;
		this.status = status;
		this.num=num;
		this.onCallPhoneDialogListener = onCallPhoneDialogListener;
	}

	public interface OnCallPhoneDialogListener {
		public void onFirst();
		public void onSecond();
	}

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.view_dialog_callphone_number_note);
		tvRenzhengContent = (TextView) findViewById(R.id.tv_renzheng_content);
		tvCallPhoneNum = (TextView) findViewById(R.id.tv_callphone_number);
		btnFirstButton = (Button) findViewById(R.id.btn_callphone_firstbutton);
		btnSecondButton = (Button) findViewById(R.id.btn_callphone_secondbutton);
		ivBiaoQing=(ImageView)findViewById(R.id.iv_callphone_biaoqing);
		try {
			if(num>0){
				ivBiaoQing.setBackgroundResource(R.drawable.iv_bq_2);
				tvCallPhoneNum.setText("今天还能拨打"+num+"次电话");
				if(status==0){
					tvRenzhengContent.setText("您还没进行认证，");	
					btnFirstButton.setText("认证");
					btnSecondButton.setText("打电话");
				}else if(status==1){
					tvRenzhengContent.setText("您的认证正在审核中，");
					btnFirstButton.setText("打电话");
					btnSecondButton.setText("返回");
				}else if(status==3){
					tvRenzhengContent.setText("您的认证未通过");
					btnFirstButton.setText("再次认证");
					btnSecondButton.setText("打电话");
				}
				
			}else{			
				ivBiaoQing.setBackgroundResource(R.drawable.iv_bq_1);
				btnSecondButton.setText("返回");
				if(status==0){	
					btnFirstButton.setText("认证");
					tvRenzhengContent.setText("今天拨打电话的次数已经用完，");
					tvCallPhoneNum.setText("认证后可以无限制拨打，或请明天重试");
				}else if(status==1){
					btnFirstButton.setVisibility(View.GONE);
					tvRenzhengContent.setText("您的认证正在审核中，");
					tvCallPhoneNum.setText("今天拨打电话的次数已经用完");
					btnSecondButton.setText("返"+"  "+"回");
				}else if(status==3){
					btnFirstButton.setText("再次认证");
					tvRenzhengContent.setText("您的认证未通过");
					tvCallPhoneNum.setText("今天拨打电话的次数已经用完");
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		
		btnFirstButton.setOnClickListener(new View.OnClickListener() {

			@Override
			public void onClick(View v) {
				onCallPhoneDialogListener.onFirst();
				dismiss();
			}
		});

		btnSecondButton.setOnClickListener(new View.OnClickListener() {

			@Override
			public void onClick(View v) {
				onCallPhoneDialogListener.onSecond();
				dismiss();
			}
		});
	}

}
